﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Windows.Data;

namespace WPFTimelineToggleBands
{
	public class StringDateTimeValueConverter : IValueConverter
	{
		#region Implementation of IValueConverter

		public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
		{
			DateTime dt;
			if (DateTime.TryParse(value as string, out dt))
			{
				return dt;
			}
			return null;
		}

		public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
		{
			if (value != null)
			{
				return ((DateTime)value).ToString();
			}
			return string.Empty;
		}

		#endregion
	}
}
